package com.xiaomi.pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

//商品表
public class Commoditys implements Serializable {

    private int cid;//商品表id
    private int pbid;//商品类型id
    private String comname;//商品名称
    private String describe;//商品描述
    private int comstate;//商品状态 1上架 2下架
    private String picturepath;//图片路径
    private Date revision_time;//上架/下架时记录时间
    private int recommend;//是否推荐1推荐

    private List<Describes> describesList;//商品详情表信息

    private double minpraice;//商品最低价格

    //通过包装类Integer转成整数
    public Integer getMinpraice() {
        Integer a = new Double(minpraice).intValue();
        return a;
    }

    public void setMinpraice(double minpraice) {
        this.minpraice = minpraice;
    }

    public List<Describes> getDescribesList() {
        return describesList;
    }

    public void setDescribesList(List<Describes> describesList) {
        this.describesList = describesList;
    }

    public int getRecommend() {
        return recommend;
    }

    public void setRecommend(int recommend) {
        this.recommend = recommend;
    }

    public int getCid() {
        return cid;
    }

    public void setCid(int cid) {
        this.cid = cid;
    }

    public int getPbid() {
        return pbid;
    }

    public void setPbid(int pbid) {
        this.pbid = pbid;
    }

    public String getComname() {
        if (comname.indexOf("(") >= 0) {
            String[] a = comname.split("\\(");
            return a[0];
        } else if (comname.indexOf("（") >= 0) {
            String[] a = comname.split("（");
            return a[0];
        } else if (comname.indexOf("小米") >= 0 && comname.indexOf("米家") >= 0) {
            String[] a = comname.split("小米");
            return a[1];
        }
        return comname;
    }

    public void setComname(String comname) {
        this.comname = comname;
    }

    public String getDescribe() {
        return describe;
    }

    public void setDescribe(String describe) {
        this.describe = describe;
    }

    public int getComstate() {
        return comstate;
    }

    public void setComstate(int comstate) {
        this.comstate = comstate;
    }

    public String getPicturepath() {
        String[] path = picturepath.split(",");
        return path[0];
    }

    public void setPicturepath(String picturepath) {
        this.picturepath = picturepath;
    }

    public Date getRevision_time() {
        return revision_time;
    }

    public void setRevision_time(Date revision_time) {
        this.revision_time = revision_time;
    }

    @Override
    public String toString() {
        return "Commoditys{" +
                "cid=" + cid +
                ", pbid=" + pbid +
                ", comname='" + comname + '\'' +
                ", describe='" + describe + '\'' +
                ", comstate=" + comstate +
                ", picturepath='" + picturepath + '\'' +
                ", revision_time=" + revision_time +
                '}';
    }
}
